﻿using Dapper;
using Microsoft.Data.SqlClient;
using System;
using System.IO;
using YfShlErp.Model;

namespace YfShlErp.DAL
{
    public class sql
    {
        private string connectionString = "Data Source=DESKTOP-15QIR3B;Initial Catalog=YFSHLerpDB;Integrated Security=True;TrustServerCertificate=True";

        public bool CheckUserCount(string username, string password)
        {
            using (var connection = new SqlConnection(connectionString))
            {
                connection.Open();

                var user = connection.Query<User>(
                    "SELECT * FROM Users WHERE Name = @Username AND Password = @Password",
                    new { Username = username, Password = password }).FirstOrDefault();

                return user != null;
            }
        }
    }
}